package com.feedback.ui;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import com.feedback.a.a;
import com.feedback.a.b;
import com.feedback.a.c;
import com.feedback.a.d;
import com.feedback.a.e;
import com.feedback.b.c;
import com.feedback.b.d;
import com.mobclick.android.t;
import java.util.Collections;
import java.util.List;
import org.json.JSONArray;

public class g extends BaseAdapter
{
  LayoutInflater a;
  Context b;
  List c;
  JSONArray d;
  String[] e;
  String f = "";
  String g = "FeedbackListAdapter";

  public g(Context paramContext, List paramList)
  {
    this.b = paramContext;
    this.a = LayoutInflater.from(paramContext);
    Collections.sort(paramList);
    this.c = paramList;
  }

  private String a(d paramd)
  {
    return paramd.d.a();
  }

  private String b(d paramd)
  {
    String str;
    int i;
    if (paramd.b == e.d)
    {
      i = paramd.f.size() - 1;
      if (i < 0)
        str = "";
    }
    while (true)
    {
      do
        while (true)
        {
          while (true)
          {
            while (true)
            {
              b localb;
              while (true)
              {
                while (true)
                {
                  return str;
                  localb = paramd.a(i).g;
                  if (localb != b.a)
                    break;
                  str = this.b.getString(t.a(this.b, "string", "UMFbList_ListItem_State_Sending"));
                }
                if (localb != b.b)
                  break;
                str = this.b.getString(t.a(this.b, "string", "UMFbList_ListItem_State_Fail"));
              }
              if (localb != b.d)
                break;
              str = this.b.getString(t.a(this.b, "string", "UMFbList_ListItem_State_Resending"));
            }
            --i;
          }
          if (paramd.b != e.b)
            break;
          str = this.b.getString(t.a(this.b, "string", "UMFbList_ListItem_State_ReSend"));
        }
      while (paramd.b != e.a);
      str = this.b.getString(t.a(this.b, "string", "UMFbList_ListItem_State_Sending"));
    }
  }

  private String c(d paramd)
  {
    String str;
    if ((paramd.f.size() != 1) && (paramd.e.f == c.c))
      str = paramd.e.a();
    while (true)
    {
      return str;
      str = null;
    }
  }

  private String d(d paramd)
  {
    return d.a(paramd.e.e, this.b);
  }

  public e a(int paramInt)
  {
    return ((d)this.c.get(paramInt)).b;
  }

  public void a(List paramList)
  {
    Collections.sort(paramList);
    this.c = paramList;
  }

  public d b(int paramInt)
  {
    return ((d)this.c.get(paramInt));
  }

  public int getCount()
  {
    return this.c.size();
  }

  public Object getItem(int paramInt)
  {
    return Integer.valueOf(paramInt);
  }

  public long getItemId(int paramInt)
  {
    return paramInt;
  }

  public View getView(int paramInt, View paramView, ViewGroup paramViewGroup)
  {
    View localView2;
    h localh2;
    String str2;
    String str3;
    if ((paramView == null) || (paramView.getTag() == null))
    {
      View localView1 = this.a.inflate(t.a(this.b, "layout", "umeng_analyse_feedback_conversations_item"), null);
      h localh1 = new h(this);
      localh1.a = ((ImageView)localView1.findViewById(t.a(this.b, "id", "umeng_analyse_new_reply_notifier")));
      localh1.b = ((TextView)localView1.findViewById(t.a(this.b, "id", "umeng_analyse_feedbackpreview")));
      localh1.c = ((TextView)localView1.findViewById(t.a(this.b, "id", "umeng_analyse_dev_reply")));
      localh1.d = ((TextView)localView1.findViewById(t.a(this.b, "id", "umeng_analyse_state_or_date")));
      localView1.setTag(localh1);
      localView2 = localView1;
      localh2 = localh1;
      d locald = (d)this.c.get(paramInt);
      String str1 = a(locald);
      str2 = c(locald);
      str3 = b(locald);
      String str4 = d(locald);
      localh2.b.setText(str1);
      if (str2 != null)
        break label301;
      localh2.c.setVisibility(8);
      if (!(d.a(str3)))
        break label323;
      localh2.d.setText(str4);
      if (!(c.a(this.b, locald)))
        break label336;
      localh2.a.setVisibility(0);
      localh2.a.setBackgroundResource(t.a(this.b, "drawable", "umeng_analyse_point_new"));
    }
    while (true)
    {
      while (true)
      {
        while (true)
        {
          while (true)
          {
            return localView2;
            localh2 = (h)paramView.getTag();
            localView2 = paramView;
          }
          label301: localh2.c.setVisibility(0);
          localh2.c.setText(str2);
        }
        label323: localh2.d.setText(str3);
      }
      label336: localh2.a.setVisibility(4);
    }
  }
}